import Types from '../mutation-types';
import store from '../store'
const state = {
	defaultProductTerms:36,
	systemConfig: {},
	defaultCarName:'A180'
}
const mutations = {
  //array
  //[{a:}
  //{a:{a1,a2,a3},b:{},c:{}}
    [Types.GET_SYSTEM_CONFIG_SUCCESS](state,data){
      let results={}
      _.forEach(data,function(item){
        let key = item.SetType
        let name = item.SetCode
        let value = item.SetValue
        if(results[key]==null){
          results[key]={}
        }
        results[key][name]=value
      })
      state.systemConfig=results
    },
    [Types.GET_SYSTEM_CONFIG_FAILURE](state,data){
      console.erro("get system config failed",data.errorMsg)
    }
}

export default {
	state,
	mutations
}
